//将数据库相关的操作抽离处理
const FoodModel = require('../db/model/foodModel')
//插入食品
let insertFood = async (obj)=>{
  let result =await FoodModel.insertMany(obj)
  console.log(result)
}
//查询全部菜品
let findFood = async ()=>{
  let result = await FoodModel.find()
  return result
}
//删除菜品

let delFood = async (_id)=>{
  // _id 就是要删除的菜品主键id
  let result = await FoodModel.deleteOne({_id})
  return result
}
//修改菜品
let updateFood =async(_id,updateInfo)=>{
  let result = FoodModel.updateOne({_id},updateInfo)
  return result
}


module.exports = {insertFood,findFood,delFood,updateFood}
